﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ContratoDetalhe.aspx.cs" Inherits="welwitschia.Contratos.ContratoDetalhe" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" language="javascript">
        $(function () {
            $("#tabs").tabs();
        });

        $(function () {
            $("#<%=txtDataContrato.ClientID%>").datepicker();
            $("#<%=txtDataInicioContrato.ClientID%>").datepicker();
            $("#<%=txtDataFimContrato.ClientID%>").datepicker();
        });

        $(function () {
            $("#dialog-form").dialog({
                autoOpen: false,
                height: 300,
                width: 350,
                modal: true,
                buttons: {
                    "Cancelar": function () {
                        $(this).dialog("close");
                    }
                },
                close: function () {
                }
            });

            $("#PesquisaUnidade")
			.button()
			.click(function () {
			    $("#dialog-form").dialog("open");
			});
        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="formulario">
        <div id="header" class="info">
            <h2>
                Informação de Contrato</h2>
            <div>
            </div>
        </div>
        <ul class="formularioConteudo">
            <li class="metadeEsquerda">
                <label class="desc" id="lblNumeroContrato">
                    Contrato<span id="req_3" class="req"> *</span></label>
                <span>
                    <asp:TextBox ID="txtNumeroContrato" CssClass="text" size="4" runat="server" Enabled="false"
                        Width="50"></asp:TextBox>
                    <label>
                        Número</label>
                </span><span>
                    <asp:TextBox ID="txtDataContrato" CssClass="text required" size="20" runat="server"></asp:TextBox>
                    <label>
                        Data</label>
                </span></li>
            <li class="metadeDireita">
                <label class="desc" id="lblValidadeContratoInicio">
                    Validade<span id="Span3" class="req"> *</span></label>
                <span>
                    <asp:TextBox ID="txtDataInicioContrato" CssClass="text required" runat="server"></asp:TextBox>
                    <label>
                        Data Início</label>
                </span><span>
                    <asp:TextBox ID="txtDataFimContrato" CssClass="text required" runat="server"></asp:TextBox>
                    <label>
                        Data Fim</label>
                </span></li>
            <li class="metadeEsquerda">
                <label class="desc" id="Label1">
                    Cliente<span id="Span1" class="req"> *</span></label>
                <div>
                    <asp:DropDownList AutoPostBack="true" ID="ddlCliente" runat="server" CssClass="select medium"
                        OnSelectedIndexChanged="ddlCliente_SelectedIndexChanged">
                    </asp:DropDownList>
                </div>
            </li>
            <li class="metadeDireita">
                <label class="desc" id="lblUnidade">
                    Unidade<span id="Span2" class="req"> *</span></label>
                <div>
                    <asp:DropDownList ID="ddlUnidade" CssClass="select medium" runat="server">
                    </asp:DropDownList>
                    <input type="button" id="PesquisaUnidade" value="..." />
                </div>
            </li>
        </ul>
    </div>
    <br />
    <br />
    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">Refeicoes</a></li>
        </ul>
        <div id="tabs-1">
            <asp:ListView runat="server" ID="lvRefeicoes" DataKeyNames="IdRefeicaoContratada"
                OnItemDeleting="lvRefeicoes_ItemDeleting" OnItemEditing="lvRefeicoes_ItemEditing"
                OnItemCommand="lvRefeicoes_ItemCommand">
                <LayoutTemplate>
                    <table runat="server" class="grd" id="table1">
                        <thead>
                            <tr class="ghdr">
                                <td>
                                    <asp:Label ID="Label2" runat="server">Refeição</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label3" runat="server">Tipo</asp:Label>
                                </td>
                                <td>
                                    <asp:Label ID="Label5" runat="server">&nbsp;</asp:Label>
                                </td>
                            </tr>
                        </thead>
                        <tr runat="server" id="itemPlaceholder">
                        </tr>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr id="Tr1" runat="server">
                        <td id="Td2" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="Label4" runat="server" Text='<%#Eval("TipoRefeicao.Descricao") %>' />
                        </td>
                        <td id="Td1" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:Label ID="lblUnidade" runat="server" Text='<%#Eval("TipoClasseRefeicao.Descricao") %>' />
                        </td>
                        <td id="Td3" runat="server">
                            <%-- Data-bound content. --%>
                            <asp:LinkButton ID="EditButton" CommandName="Edit" CommandArgument='<%# Eval("IdRefeicaoContratada")%>'
                                runat="server" Text="Editar"></asp:LinkButton>
                            <asp:LinkButton ID="DeleteButton" OnClientClick="return confirm('Apaga registo?');"
                                CommandName="Delete" CommandArgument='<%# Eval("IdRefeicaoContratada")%>' runat="server"
                                Text="Apagar"></asp:LinkButton>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:ListView>
            <div style="margin: 10px 5px 0px 10px">
                <asp:Button ID="btnAdRefeicao" runat="server" Text="Adicionar Refeição" OnClick="btnAdRefeicao_Click" />
            </div>
        </div>
    </div>
    <div class="pageCommandArea">
        <asp:Button ID="btnGravar" runat="server" Text="Gravar" OnClick="btnGravar_Click" />
        <asp:Button ID="btnVoltar" runat="server" Text="Voltar" OnClick="btnVoltar_Click" />
    </div>
    <div id="dialog-form" title="Seleccionar Unidade">
       <asp:TreeView ID="tvUnidades" runat="Server"
                        ShowLines="false" 
                        ShowExpandCollapse="true" 
                          ViewStateMode="Enabled" 
            onselectednodechanged="tvUnidades_SelectedNodeChanged">
                        <NodeStyle Font-Underline="true" />
                        <SelectedNodeStyle Font-Underline="false" Font-Bold="true"/>
      </asp:TreeView>
    </div>
</asp:Content>
